package com.cloud.DrugManagement.service.Impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloud.DrugManagement.mapper.StockMapper;
import com.cloud.DrugManagement.pojo.Stock;
import com.cloud.DrugManagement.service.StockService;
import org.springframework.stereotype.Service;

/**
 * @author zhozixiong
 * @date 2023/02/06
 */
@Service
public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements StockService {

    private final int SIZE = 10;

    @Override
    public Page<Stock> searchAllByDidOrDname(int pages, Object parameter) {
        Page page = new Page(pages, SIZE);
        return baseMapper.searchAllByDidOrDname(page, parameter);
    }

    @Override
    public int searchQuantityByDid(int did) {
        return baseMapper.searchQuantityByDid(did);
    }

    @Override
    public boolean updateQuantityByDid(int dId, int quantity) {
        return baseMapper.updateQuantityByDid(dId, quantity) >= 1;
    }
}
